//Page Object
Page({
    data: {
        // 一级标签
        tabs: [
            {
                index: 0,
                value: '商品收藏',
                isActive: true
            },
            {
                index: 1,
                value: '品牌收藏',
                isActive: false
            },
            {
                index: 2,
                value: '店铺收藏',
                isActive: false
            },
            {
                index: 3,
                value: '浏览足迹',
                isActive: false
            }
        ],
        // 二级标签
        goods_tabs: [
            {
                index: 0,
                value: '全部',
                isActive: true
            },
            {
                index: 1,
                value: '正在热卖',
                isActive: false
            },
            {
                index: 2,
                value: '即将上线',
                isActive: false
            }
        ],
        collect: []
    },
    //options(Object)
    onLoad: function(options){
        
    },
    onReady: function(){
        
    },
    onShow: function(){
        const collect = wx.getStorageSync('collect');
        this.setData({
            collect
        })
        
    },
    onHide: function(){

    },
    onUnload: function(){

    },
    onPullDownRefresh: function(){

    },
    onReachBottom: function(){

    },
    onShareAppMessage: function(){

    },
    onPageScroll: function(){

    },
    //item(index,pagePath,text)
    onTabItemTap:function(item){

    },
    // 一级标签单击事件
    handleItemTap(e) {
        const {index} = e.detail;
        const {tabs} = this.data;
        tabs.forEach((v,i) => i===index ? v.isActive=true : v.isActive=false);
        this.setData({
            tabs
        })
    },    
    // 二级标签单击事件
    handleGdsTabsTap(e) {
        const {index} = e.currentTarget.dataset;
        const {goods_tabs} = this.data;
        goods_tabs.forEach((v,i) => i===index ? v.isActive=true : v.isActive=false);
        this.setData({
            goods_tabs
        })
    }
});